﻿Public Class InPutVerts
    Private m_Line As CAermod.Line
    Property Line() As CAermod.Line
        Get
            Return Me.m_Line
        End Get
        Set(ByVal value As CAermod.Line)
            Me.m_Line = value
        End Set
    End Property

    Private Sub InPutVerts_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        RefreshData()
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.OK = Windows.Forms.DialogResult.Cancel
        CloseDropDown(True)
    End Sub

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        Me.DialogResult = Windows.Forms.DialogResult.OK
        CloseDropDown(True)
    End Sub

    Private Sub EFlex1_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles EFlex1.Validating
        ReDim Preserve m_Line.LinePoints(Me.EFlex1.Rows.Count - 1)
        For i As Integer = 1 To m_Line.LinePoints.Length - 1
            m_Line.LinePoints(i).x = Me.EFlex1.GetData(i, 1)
            m_Line.LinePoints(i).y = Me.EFlex1.GetData(i, 2)
            m_Line.LinePoints(i).z = Me.EFlex1.GetData(i, 3)
        Next
    End Sub
    Private Sub RefreshData()
        Me.EFlex1.Rows.Count = m_Line.LinePoints.Length
        For i As Integer = 1 To m_Line.LinePoints.Length - 1
            Me.EFlex1.SetData(i, 0, i)
            Me.EFlex1.SetData(i, 1, m_Line.LinePoints(i).x)
            Me.EFlex1.SetData(i, 2, m_Line.LinePoints(i).y)
            Me.EFlex1.SetData(i, 3, m_Line.LinePoints(i).z)
        Next
    End Sub
    Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
        ReDim Preserve m_Line.LinePoints(m_Line.LinePoints.Length)
        m_Line.LinePoints(m_Line.LinePoints.Length - 1) = New CAermod.Point3D
        RefreshData()
    End Sub

   
    Private Sub cmdDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDel.Click
        If m_Line.LinePoints.Length > 2 Then
            ReDim Preserve m_Line.LinePoints(m_Line.LinePoints.Length - 2)
            RefreshData()
        End If
    End Sub

    Private Sub InPutVerts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.EFlex1.Styles.Alternate.BackColor = Color.FromArgb(216, 228, 248)
        Me.EFlex1.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
        Me.EFlex1.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None
        Me.EFlex1.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
    End Sub
End Class
